import { Component, OnInit } from '@angular/core';
import { ProductService, Product } from '../shared/product.service';
import {FormControl} from '@angular/forms';
import "rxjs/Rx";

@Component({
  selector: 'app-product',
  templateUrl: './product.component.html',
  styleUrls: ['./product.component.css']
})
export class ProductComponent implements OnInit {
  private products:Array<Product>;
  private keywords: string;
  private titleFilter: FormControl = new FormControl();
  private imgUrl = "http://placehold.it/320X150";
  constructor(private productService: ProductService) {
    this.titleFilter.valueChanges
    .debounceTime(500)
    .subscribe(
      value => this.keywords = value
    )
   }

  ngOnInit() {
    this.products = this.productService.getProducts();
  }

}
